﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Personal_Cloud_Disk_PC_Client
{
    public class PCloudClient
    {
        public PCloudClient()
        {
            checkConfig();
            taskScheduler = new TaskScheduler();
            evnetMonitor = new EventMonitor(taskScheduler);
            clientWatcher = new ClientWatcher(evnetMonitor);
        }

        public void startSync()
        {
            if (isFirstTimeStart()) {
                fullCompareSync();
            }
            Logger.write("before startTaskScheduler()");
            startTaskScheduler();
            Logger.write("before startMonitor()");
            startMonitor();
            Logger.write("before startClientWatcher()");
            startClientWatcher();
            //startServerWatcher();
        }

        private void startTaskScheduler()
        {
            taskScheduler.start();
        }

        private void startMonitor()
        {
            evnetMonitor.start();
        }

        private void startClientWatcher()
        {
            clientWatcher.start();
        }

        private void startServerWatcher()
        {
            throw new NotImplementedException();
        }

        public void stopSync()
        {
            Logger.write("before stopClientWatcher()");
            stopClientWatcher();
            //stopServerWatcher();
            Logger.write("before stopMonitor()");
            stopMonitor();
            Logger.write("before stopTaskScheulder()");
            stopTaskScheulder();
        }

        private void stopClientWatcher()
        {
            clientWatcher.stop();
        }

        private void stopServerWatcher()
        {
            throw new NotImplementedException();
        }

        private void stopTaskScheulder()
        {
            taskScheduler.stop();
        }

        private void stopMonitor()
        {
            evnetMonitor.stop();
        }


        private void fullCompareSync()
        {
            //throw new NotImplementedException();
        }

        private void checkConfig()
        {
            //throw new NotImplementedException();
        }

        private bool isFirstTimeStart()
        {
            //throw new NotImplementedException();
            return false;
        }

        private ClientWatcher clientWatcher;
        private EventMonitor evnetMonitor;
        private TaskScheduler taskScheduler;
    }
}
